<template>
  <div>
    <h2 class="van-doc-block__title">合同列表</h2>
    <van-card
      v-for="item in lists"
      :key="item.contractId"
      @click="toContractDetail(item.contractId)"
    >
      <template #price>
        <div>乙方：{{item.acorpName}}</div>
        <div>联系人：{{item.acontacter}}</div>
        <div>联系电话：{{item.acontactPhone}}</div>
      </template>
      <template #desc>
        <div>甲方：{{item.bcorpName}}</div>
        <div>联系人：{{item.bcontacter}}</div>
        <div>联系电话：{{item.bcontactPhone}}</div>
        <div>状态：{{contractStatus[item.htztBm]}}</div>
      </template>
    </van-card>
    <van-empty image="search" v-if="lists.length == 0" description="暂无信息" />
    <loading-page v-if="loadingPage"></loading-page>
  </div>
</template>

<script>
  import {Toast} from "vant";

  export default {
    data() {
      return {
        loadingPage: true,
        query: {
          corpId: ''
        },
        contractStatus: ['申请中','平台初审','企业未确认','企业已确认'],
        lists: [],
        loading: false,
        finished: false,
      }
    },
    created() {
      this.query.corpId = this.$route.query.corpId;
      this.getdata();
    },
    methods: {
      getdata() {
        this.$Api.get("/api/cqhContract/checkContracts", this.query).then(res => {
          if (res.data.code == 200) {
            console.log(res)
            this.lists = res.data.data;
          } else {
            Toast(res.data.message);
          }
        }).catch(err => {
        });

      },
      toContractDetail(e) {
        this.$router.push({path: '/enterpriseCar/contract/detail', query: {contractId: e}})
      },
      onSearch() {
        this.getdata();
      },
      onCancel() {
        this.getdata();
      }
    }
  }
</script>

<style scoped>
  .van-doc-block__title {
    margin: 0;
    padding: 24px 16px 16px;
    color: #09f;
    font-weight: normal;
    font-size: 16px;
    line-height: 16px;
    text-align: center;
    border-bottom: 1px solid #09f;
  }

  .van-card {
    background-color: #fff;
  }

  .van-card {
    margin-top: 0;
    border-bottom: 8px solid #f5f5f5;
  }

  .van-card__bottom {
    margin-top: 10px;
  }
</style>
